package com.xdf.docmanagementsystem.service;

import com.xdf.docmanagementsystem.service.impl.ViewExcelFileImpl;
import com.xdf.docmanagementsystem.service.impl.ViewOtherFileImpl;
import com.xdf.docmanagementsystem.service.impl.ViewTextFileImpl;
import com.xdf.docmanagementsystem.service.impl.ViewWordFileImpl;
import org.apache.commons.lang3.StringUtils;

/**
 * @program: doc-management-system
 * @description:
 * @author: Zhang
 * @create: 2020-06-26 17:12
 **/
public class ViewFactory {

    /**
     * 获取
     *
     * @param suffix
     * @return
     */
    public static ViewFile getFactory(String suffix) {
        if (StringUtils.isEmpty(suffix))
            return new ViewOtherFileImpl();
        if (suffix.toUpperCase().contains("DOC")) {
            return new ViewWordFileImpl();
        } else if (suffix.toUpperCase().contains("XLS")) {
            return new ViewExcelFileImpl();
        } else if (suffix.toUpperCase().contains("TXT")) {
            return new ViewTextFileImpl();
        } else {
            return new ViewOtherFileImpl();
        }
    }
}
